// Read characters from keyboard until period is received.
// Also count number of <spaces> used.
class johnPeriod {
    public static void main(String args[]) 
        throws java.io.IOException {

        char ch, ignore;
        int counter = 0;

        do {
            ch = (char) System.in.read();

            // Uncommenting this results in only allowing standalone spaces to register
            /* do {
                ignore = (char) System.in.read();
            } while(ignore != '\n');
            */

            if(ch == ' ') counter++; // Count each time space is used.
        } while(ch != '.');
        System.out.println("A period is pressed!");
        System.out.println("Number of spaces is: " + counter);
    }
}

        
